﻿// Decompiled with JetBrains decompiler
// Type: Netick.NetworkArrayStruct8`1
// Assembly: Netick, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 6726ECA1-C773-4CF7-8952-E81B30D93B52
// Assembly location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.dll
// XML documentation location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.xml

using System;
using System.Collections;
using System.Collections.Generic;

#nullable disable
namespace Netick;

[Networked(8, Relevancy.Everyone, 0.001f, false)]
public struct NetworkArrayStruct8<T> : IEnumerable<T>, IEnumerable where T : unmanaged
{
  internal FixedSize8<T> Element0;

  public int Length => 8;

  public unsafe T this[int i]
  {
    get
    {
      if (i < 0 || i > this.Length - 1)
        throw new IndexOutOfRangeException();
      fixed (NetworkArrayStruct8<T>* networkArrayStruct8Ptr = &this)
        return ((T*) networkArrayStruct8Ptr)[i];
    }
    set
    {
      if (i < 0 || i > this.Length - 1)
        throw new IndexOutOfRangeException();
      fixed (NetworkArrayStruct8<T>* networkArrayStruct8Ptr = &this)
        ((T*) networkArrayStruct8Ptr)[i] = value;
    }
  }

  public NetworkArrayStruct8<T> Set(int index, T value)
  {
    this[index] = value;
    return this;
  }

  public IEnumerator<T> GetEnumerator()
  {
    for (int i = 0; i < this.Length; ++i)
      yield return this[i];
  }

  IEnumerator IEnumerable.GetEnumerator() => (IEnumerator) this.GetEnumerator();

  public override string ToString()
  {
    string str = "";
    for (int i = 0; i < this.Length; ++i)
      str += $" {i}:  {this[i]}";
    return str;
  }
}
